home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / mac / Sample Code / QuickTime / QuickTimeIntro / Play Movie w⁄Controller / Completed Lab / Events.c < prev    next >
Encoding:
Text File  |  2000-10-06  |  2.1 KB  |  92 lines  |  [TEXT/CWIE]

  1. // Play Movie with Controller Sample
  2. // Based on QTShell
  3. // WWDC 2000
  4.  
  5. #include "ComApplication.h"
  6. #include "ComFramework.h"
  7. #include "MacFramework.h"
  8.  
  9. //////////
  10. //
  11. // ActivateController
  12. // Activate or deactivate the movie controller in the specified window.
  13. //
  14. //////////
  15.  
  16. void ActivateController (WindowReference theWindow, Boolean IsActive)
  17. {
  18.     WindowObject         myWindowObject = NULL;
  19.     MovieController        myMC = NULL;
  20.     GrafPtr                mySavedPort = NULL;
  21.     
  22.     if (theWindow == NULL)
  23.         return;
  24.     
  25.     GetPort(&mySavedPort);
  26.     MacSetPort(QTFrame_GetPortFromWindowReference(theWindow));
  27.     
  28.     // get the window object associated with the specified window
  29.     myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow);
  30.     if (myWindowObject != NULL) {
  31.         myMC = (**myWindowObject).fController;
  32.         if (myMC != NULL)
  33.             MCActivate(myMC, QTFrame_GetWindowFromWindowReference(theWindow), IsActive);
  34.     }
  35.     
  36.     MacSetPort(mySavedPort);
  37. }
  38.  
  39. //////////
  40. //
  41. // Draw
  42. // Update the specified window.
  43. //
  44. //////////
  45.  
  46. void Draw (WindowReference theWindow, Rect *theRefreshArea)
  47. {
  48. #pragma unused(theRefreshArea)
  49.  
  50.     GrafPtr             mySavedPort;
  51.     
  52.     GetPort(&mySavedPort);
  53.     MacSetPort(QTFrame_GetPortFromWindowReference(theWindow));
  54.     
  55.     BeginUpdate(QTFrame_GetWindowFromWindowReference(theWindow));
  56.     //EraseRect(theRefreshArea);        // this is important only for non-rectangular movies
  57.     
  58.     // ***insert application-specific drawing here***
  59.     
  60.     // draw the movie controller and its movie
  61.     MCDoAction(QTFrame_GetMCFromWindow(theWindow), mcActionDraw, theWindow);
  62.     
  63.     EndUpdate(QTFrame_GetWindowFromWindowReference(theWindow));
  64.     MacSetPort(mySavedPort);
  65. }
  66.  
  67. //////////
  68. //
  69. // CheckMovieControllers
  70. // Let all movie controllers have a chance to process the event.
  71. //
  72. // Returns true if the event was handled by some movie controller, false otherwise
  73. //
  74. //////////
  75.  
  76. Boolean CheckMovieControllers (EventRecord *theEvent)
  77. {    
  78.     WindowPtr                myWindow = NULL;
  79.     MovieController            myMC = NULL;
  80.     
  81.     myWindow = QTFrame_GetFrontMovieWindow();
  82.     while (myWindow != NULL) {
  83.         myMC = QTFrame_GetMCFromWindow(myWindow);
  84.         if (myMC != NULL)
  85.             if (MCIsPlayerEvent(myMC, theEvent))
  86.                 return(true);
  87.         
  88.         myWindow = QTFrame_GetNextMovieWindow(myWindow);
  89.     }
  90.     
  91.     return(false);
  92. }